<?php
namespace admin\action;

use herosphp\http\HttpRequest;
use herosphp\utils\AjaxResult;
use herosphp\bean\Beans;

/**--tmpl-use--**/

class NodeAction extends CommonAction {

	public function C_start()
	{
		//parent::C_start();

		$this->assign('role_assoc_url','/admin/role/getAdmin_role');
		//只允许创始人修改
		if(C('originator_id') != adminId())
		{
			location('/admin/index/error/?type=danger&message='.base64_encode(self::NO_PERMISSION));
			exit();
		}

	}


	protected $serviceBean="admin.adminNode.service";


	public function getAdmin_node(HttpRequest $request) {
	
		$kw = $request->getParameter('kw');
		$request->addParameter('s_name',$kw);
		$this->index($request);
		$items = $this->getTemplateVar('items');
		$total = $this->getTemplateVar('total');
		echo json_encode(array('items' => $items,'total' => $total));
		exit;
	
	
	}
	
	public function add(HttpRequest $request) {
	
		parent::add($request);
	
	
		$this->assign("title", "权限表列表");
		$this->assign('bread', array('管理员管理',$this->getTemplateVar('title')));
		$this->assign('breadUrl', array(url('admin'), 'javascript:;'));
	
	}
	
	public function edit(HttpRequest $request) {
	
		parent::edit($request);
	
		$this->assign("title", "权限表列表");
		$this->assign('bread', array('管理员管理',$this->getTemplateVar('title')));
		$this->assign('breadUrl', array(url('admin'), 'javascript:;'));
	}
	
	public function index(HttpRequest $request) {
	
		$conditions = array();
		$s_name = $request->getParameter('s_name');
		$s_node_key = $request->getParameter('s_node_key');
		$s_remark = $request->getParameter('s_remark');
		$s_addtime = $request->getParameter('s_addtime');
		$s_edittime = $request->getParameter('s_edittime');
		$s_manager_id = $request->getParameter('s_manager_id');
		$s_del_status = $request->getParameter('s_del_status');
		$s_app_id = $request->getParameter('s_app_id');

		if($s_name !== '' && $s_name!== NULL)$conditions['name'] = '%'.$s_name.'%';
		if($s_node_key !== '' && $s_node_key!== NULL)$conditions['node_key'] = '%'.$s_node_key.'%';
		if($s_remark !== '' && $s_remark!== NULL)$conditions['remark'] = '%'.$s_remark.'%';
		if($s_addtime !== '' && $s_addtime!== NULL)$conditions['addtime'] = '%'.$s_addtime.'%';
		if($s_edittime !== '' && $s_edittime!== NULL)$conditions['edittime'] = '%'.$s_edittime.'%';
		if($s_manager_id !== '' && $s_manager_id!== NULL)$conditions['manager_id'] = '%'.$s_manager_id.'%';
		if($s_app_id !== '' && $s_app_id!== NULL)$conditions['app_id'] = '%'.$s_app_id.'%';

		$this->assign('_table','权限表');
		$this->assign('s_name',$s_name);
		$this->assign('s_node_key',$s_node_key);
		$this->assign('s_remark',$s_remark);
		$this->assign('s_addtime',$s_addtime);
		$this->assign('s_edittime',$s_edittime);
		$this->assign('s_manager_id',$s_manager_id);
		$this->assign('s_del_status',$s_del_status);
		$this->assign('s_app_id',$s_app_id);
		$this->assign('_filter',array('name','node_key','remark','addtime','edittime','admin_manager_id','del_status','app_id'));
		$this->assign('_header',array('','','','','','','','AppId'));
		$this->setConditions($conditions);
	
		$pagesize = $request->getParameter('pagesize') ? $request->getParameter('pagesize') : $this->getPagesize();
		$order = $request->getParameter('order') ? $request->getParameter('order') : $this->getOrder();
		$order = str_replace('+' , " ",$order);
		$this->setPagesize($pagesize);
		$this->setOrder($order);
		$this->assign('order',$order);
		$this->assign('pagesize',$pagesize);
		parent::index($request);
	
	
		$this->assign("title", "权限表列表");
		$this->assign('bread', array('管理员管理',$this->getTemplateVar('title')));
		$this->assign('breadUrl', array(url('admin'),'javascript:;'));
	}
	
	public function do_add(HttpRequest $request)
	{
		$data = $request->getParameter('data');
	
		$request->addParameter('data',$data);
		parent::do_add($request);	
	}
	
	public function do_edit(HttpRequest $request){
		$data = $request->getParameter('data');
	
		$request->addParameter('data',$data);
		parent::do_edit($request);	
	}
	
	

}
